package com.share.demo.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * craated by caifan
 */
public class CallableDemo implements Callable<String> {
    @Override
    public String call() throws Exception {
        StringBuilder builder = new StringBuilder();
        for (int i=0;i<3;i++) {
            builder.append("callTest" + i);
        }
        return builder.toString();
    }

    public static void main(String[] args) throws Exception {
        FutureTask futureTask = new FutureTask(new CallableDemo());
        new Thread(futureTask).start();
        System.out.println(futureTask.get().toString());
    }

}
